from playhouse.migrate import *

# 连接数据库
db_log = MySQLDatabase('db_log', user='root', password='HHup7856_@pp', host='localhost', port=3306)


# console log
class ConsoleLog(Model):
    time = BigIntegerField(default=0, index=True)
    level = CharField(max_length=10, default='info', index=True)
    content = CharField(max_length=2048, default='')
    time_str = CharField(max_length=20, default='')
    
    class Meta:
        database = db_log


# console log
class UserAction(Model):
    time = BigIntegerField(default=0, index=True)
    time_str = CharField(max_length=20, default='')
    req = CharField(max_length=2048, default='')
    resp = CharField(max_length=2048, default='')
    user = CharField(max_length=200, default='')

    class Meta:
        database = db_log


if __name__ == "__main__":
    ConsoleLog.create_table()
    UserAction.create_table()

